﻿using SuperSocket.SocketBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace MySuperSocketServer.Filter.ConnectionFilter
{
    /// <summary>
    /// Ip连接过滤器
    /// </summary>
    public class IPConnectionFilter : IConnectionFilter
    {
        public string Name { get; private set; }

        public bool Initialize(string name, IAppServer appServer)
        {
            Name = name;
            return true;
        }

        public bool AllowConnect(IPEndPoint remoteAddress)
        {
            bool result = true;

            var ip = remoteAddress.Address.ToString();
            //过滤逻辑
            if(ip.Trim()== "*.*.*.*")
            {
                result = false;
            }

            return result;
        }
    }
}
